package org.je.ufo;

/**
 * ufo : useful object
 * 
 * @author fan yi feng
 */
public class Loop
{
	private int			index	= -1;
	private final int	maxIndex;

	/**
	 * @param size
	 */
	public Loop(int size) {
		if (size < 1)
			throw new IllegalArgumentException("size<=0");
		maxIndex = size - 1;
	}

	/**
	 * @return
	 */
	public synchronized int index() {
		if (index < maxIndex)
			++index;
		else
			index = 0;
		return index;
	}

}
